<?php

    include "../../config.php";


 //获取未整理的数据一条
    $_data=select_lines_all_items($table_prefix."facebook_page_url",'nid asc',"email is null and collect_status = 'done' and phone is null and website is null and remark is not null",'1');

    //print_r2($_data);
    //然后把remark递交到ai api处理
    //echo $_data[0]['remark'];


    $content="从这个数据中提取出：电话号码，邮箱，网站地址，然后返回一个json格式。只返回json即可，不需要任何解析和说明。数据如下："
            .$_data[0]['remark'].
            "电话记录在phone，邮箱记录在email,网址记录在website。";

    include_once "../system/tongyiqianwen/common_ask_need_question.php";


    //echo $_result;
    //返回获取到的json格式，重新入库

    //```json
    //{
    //  "phone": "",
    //  "email": "sarah@theweddingplanningqueen.com",
    //  "website": "www.sarahlouiseweddingplanner.co.uk"
    //}
    //```
    //
    //$_result转换成数组
    $_result=str_replace("```json","",$_result);
    $_result=str_replace("```","",$_result);
    $_result=str_replace("json","",$_result);
    $_result=json_decode($_result,true);




    $_data2['nid']=$_data[0]['nid'];
    $_data2['ai_phone']=$_result['phone'];
    $_data2['ai_email']=$_result['email'];
    $_data2['ai_website']=$_result['website'];

    print_r2($_data2);

    echo $_sql=update_date($table_prefix."facebook_page_url",$_data2,"nid",$_data[0]['nid']);
    $query = mysql_query($_sql) or die (mysql_error().$_sql);

?>

<body>
<!--写一个js，每隔5秒自动刷新一次循环一次，循环310次-->
<script>
    var i = 0;
    setInterval(function(){
        if(i < 310){
            window.location.reload();
            i++;
        }
    }, 2000);
</script>
</body>